package src.twice;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class Decompressing {

    public static void main(String[] args) {
        ZipInputStream zin ;
        try {
            zin = new ZipInputStream(new FileInputStream("C:\\Users\\22528\\Desktop\\image.zip"));
            ZipEntry entry = zin.getNextEntry();
            while (((entry=zin.getNextEntry())!=null)&&!entry.isDirectory()){
                File file = new File(entry.getName());
                System.out.println("name:"+entry.getName());
                if(!file.exists()){
                    file.createNewFile();
                }
                zin.closeEntry();
                System.out.println("解压成功");
            }
            zin.close();
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
